package shmallarchitect.jpa.entities;
// Generated 2009-08-23 21:22:13 by Hibernate Tools 3.2.1.GA


import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Locum generated by hbm2java
 */
@Entity
@Table(name="locum"
    ,catalog="shmall_architect"
)
public class Locum  implements java.io.Serializable {


     private Long id;
     private Card card;
     private Gallery gallery;
     private Owner owner;
     private String name;
     private Set<Field> fields = new HashSet<Field>(0);
     private Set<Category> categories = new HashSet<Category>(0);

    public Locum() {
    }

	
    public Locum(Card card, Gallery gallery, Owner owner, String name) {
        this.card = card;
        this.gallery = gallery;
        this.owner = owner;
        this.name = name;
    }
    public Locum(Card card, Gallery gallery, Owner owner, String name, Set<Field> fields, Set<Category> categories) {
       this.card = card;
       this.gallery = gallery;
       this.owner = owner;
       this.name = name;
       this.fields = fields;
       this.categories = categories;
    }
   
     @Id @GeneratedValue(strategy=IDENTITY)
    
    @Column(name="id", unique=true, nullable=false)
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="card_id", nullable=false)
    public Card getCard() {
        return this.card;
    }
    
    public void setCard(Card card) {
        this.card = card;
    }
@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="gallery_id", nullable=false)
    public Gallery getGallery() {
        return this.gallery;
    }
    
    public void setGallery(Gallery gallery) {
        this.gallery = gallery;
    }
@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="owner_id", nullable=false)
    public Owner getOwner() {
        return this.owner;
    }
    
    public void setOwner(Owner owner) {
        this.owner = owner;
    }
    
    @Column(name="name", nullable=false)
    public String getName() {
        return this.name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY, mappedBy="locum")
    public Set<Field> getFields() {
        return this.fields;
    }
    
    public void setFields(Set<Field> fields) {
        this.fields = fields;
    }
@ManyToMany(cascade=CascadeType.ALL, fetch=FetchType.LAZY)
    @JoinTable(name="locumcategory", catalog="shmall_architect", joinColumns = { 
        @JoinColumn(name="locum_id", nullable=false, updatable=false) }, inverseJoinColumns = { 
        @JoinColumn(name="category_id", nullable=false, updatable=false) })
    public Set<Category> getCategories() {
        return this.categories;
    }
    
    public void setCategories(Set<Category> categories) {
        this.categories = categories;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Locum other = (Locum) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 37 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return id + ":" + name;
    }




}


